
{extend name='public/base' /}

{block name="content"}

<div class="layui-col-md12">
    <div class="layui-card">
        <div class="layui-card-body">
            <form action="" class="layui-form" method="get">
                <div class="layui-form-item layui-form-pane">

                    <div class="layui-inline">
                        <label class="layui-form-label">商户：</label>
                        <div class="layui-input-inline">
                            <select name="merchant_id" lay-verify="required" lay-search="">
                                <option value="0" ></option>
                                {volist name="merchant_list" id="t"}
                                {if empty($t.name)||$t.name=='-'}
                                <option value="{$t.id}" >{$t.company} - {$t.code}-{$t.biz_state}-{$t.positions_code}</option>
                                {else/}
                                <option value="{$t.id}" >{$t.name} - {$t.code}-{$t.biz_state}-{$t.positions_code}</option>
                                {/if}
                                {/volist}
                            </select>
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">选择时间：</label>
                        <div class="layui-input-inline">
                            <input type="text" class="layui-input" name="time" id="time" placeholder="">
                        </div>
                    </div>
                    <div class="layui-inline">
                        <button class="layui-btn icon-btn layui-btn-sm" data-id="table_id" lay-filter="search" lay-submit="">
                            <i class="layui-icon"></i>搜索
                        </button>
                        <button type="reset" class="layui-btn icon-btn layui-btn-normal layui-btn-sm"><i class="layui-icon layui-icon-refresh"></i>{:__('Reset')}</button>
                    </div>
                </div>
            </form>
        </div>
    </div>
    <div class="layui-card">
        <div class="layui-card-body">
            <table class="layui-hide" id="table_id" lay-filter="table_id"></table>
        </div>
    </div>

</div>
{/block}

{block name="js"} <!--js处理区-->


<script type="text/html" id="toolbarDemo">
    <div class="layui-btn-container">
        <button type="button" lay-event="reload"  class="layui-btn  layui-btn-sm  layui-btn-primary">刷新表格</button>
    </div>
</script>

<script>
    layui.use(['element', 'table', 'form', 'jquery', 'lucky','opTable','laydate'], function () {
        var element = layui.element;
        var form = layui.form;
        var table = layui.table;
        var $ = layui.jquery;
        var laydate = layui.laydate;
        var lucky=layui.lucky;
        var opTable = layui.opTable;
        form.render();
        laydate.render({
            elem: '#time'
            ,type: 'date',
            range:'~',
            trigger: 'click'
        });
        var myTables = table.render({
            elem: '#table_id',
            url:"{:url('index')}",
            where: { info_type: 2},
            toolbar: '#toolbarDemo', //开启头部工具栏，并为其绑定左侧模板
            defaultToolbar: ['filter', 'exports', 'print'],
            even: true, //开启隔行背景
            id:'table_id',
            page: { //支持传入 laypage 组件的所有参数（某些参数除外，如：jump/elem） - 详见文档
                layout: ['limit', 'count', 'prev', 'page', 'next', 'skip','last'] //自定义分页布局
                ,groups: 5 //只显示 1 个连续页码
                ,first: false //不显示首页
                ,last: false //不显示尾页
                ,limit:20
                ,limits:[10,20,30,50]
            },
            // height: 'full-100',100',
            text: {
                none: '暂无相关数据'
            },
            cols: [[
                { title: '', type: 'checkbox', fixed: true},
                { title: 'ID', field: 'id'},
                { title: '商户名', field: 'merchant_user',templet:function (item) {
                    return item.merchant.name
                }},
                { title: '合同号', field: 'merchant_user',templet:function (item) {
                        return item.merchant.code
                    }},
                { title: '表号', field: 'electrity_type',templet:function (item){
                        return item.watch.pointName
                    }},
                { title: '类型', field: 'pay_status',templet:function (item) {
                    if(item.type==3){
                        return '普通电表';
                    }else {
                        return '普通水表';
                    }
                    }},
                { title: '上期指数', field: 'last_electricity' , },
                { title: '本期指数', field: 'now_electricity' ,},
                { title: '实际用电指数', field: 'add_user' ,templet:function (item){
                        return (item.now_electricity-item.last_electricity).toFixed(2);
                    } },
                { title: '倍率', field: 'rate' ,templet:function (item){
                        return item.watch.rate
                    }},
                { title: '实际用电量', field: 'add_user' ,templet:function (item){
                        return ((item.now_electricity-item.last_electricity)*item.watch.rate).toFixed(2);
                    }},
                { title: '上期录入时间', field: 'last_time' , templet:function (item){
                       return   layui.util.toDateString((item.last_time)*1000)
                    }},
                { title: '本期录入时间', field: 'now_time' , templet:function (item){
                        return   layui.util.toDateString((item.now_time)*1000)
                    } },
                { title: '抄表人', field: 'meterReading' ,},
            ]],
            //  展开的列配置
            openCols: [
                {field: 'desc', title: '描述信息'}
            ],
            done: function (res) {
                layer.closeAll('loading');
            }
        });
        /**
         * 关键词搜索树
         */
        form.on('submit(search)', function (obj) {
            lucky.CreateSearch(obj.field);
            return false;
        });
    });

</script >

{/block}
